# 百度贴吧图片下载
import requests
from lxml import etree

url = "https://tieba.baidu.com/p/5475267611"
response = requests.get(url).text
# print(response)
selector = etree.HTML(response)
image_urls = selector.xpath('//img[@class="BDE_Image"]/@src')
# print(image_urls)
offset = 0
for image_url in image_urls:
    image_content = requests.get(image_url).content

    with open('{}.jpg'.format(offset), 'wb') as f:
        f.write(image_content)
    offset += 1
